package com.xbongbong.pro.rabbitmq.producer.impl;

import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.pro.message.pojo.dto.AutoClueAssignmentRabbitMqDTO;
import com.xbongbong.pro.rabbitmq.binders.AutoClueAssignmentProducerBinder;
import com.xbongbong.pro.rabbitmq.producer.AutoClueAssignmentProducer;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author long
 * @version v1.0
 * @date 2021/1/18 10:04
 * @since v1.0
 */
@Service("autoClueAssignmentProducer")
@EnableBinding(AutoClueAssignmentProducerBinder.class)
public class AutoClueAssignmentProducerImpl implements AutoClueAssignmentProducer {

    @Resource
    private AutoClueAssignmentProducerBinder autoClueAssignmentProducerBinder;

    @Override
    public void autoClueAssignment(AutoClueAssignmentRabbitMqDTO autoClueAssignmentRabbitMqDTO) throws XbbException {
        MessageBuilder messageBuilder = MessageBuilder.withPayload(autoClueAssignmentRabbitMqDTO);
        autoClueAssignmentProducerBinder.autoClueAssignmentOutput().send(messageBuilder.build());
    }
}
